package com.youku.expression.ast;

import com.youku.expression.Token;

public class OpGTAst extends OpAst {

	public OpGTAst(Token op, Ast sumExp, Ast sumedExp) {
		super(op, sumExp, sumedExp);
	}

	@Override
	protected Object operate(Object left, Object right) {
		if (left instanceof Number && right instanceof Number) {
			Number leftNumber = (Number) left;
			Number rightNumber = (Number) right;
			if (leftNumber instanceof Double || rightNumber instanceof Double) {
				return leftNumber.doubleValue() > rightNumber.doubleValue();
			} else if (leftNumber instanceof Long || rightNumber instanceof Long) {
				return leftNumber.longValue() > rightNumber.longValue();
			} else {
				return leftNumber.intValue() > rightNumber.intValue();
			}
		}
		return getTypeComparator().compare(left, right) > 0;
	}

}
